package com.wc.alorithm_luogu.P1540;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Queue;

/**
 * @Author congge
 * @Date 2023/5/15 21:34
 * @description https://www.luogu.com.cn/problem/P1540
 * 机器翻译
 * 典型的队列问题，也是操作系统中，缺页中断中的处理方式的FIFO
 * 但是还有查询功能
 */
public class Main {
    public static void main(String[] args) {
        Input sc = new Input();

        int m = sc.nextInt();
        int n = sc.nextInt();

        // 队列
        Queue<Integer> queue = new LinkedList<Integer>();

        // 方便查询工作
        HashSet<Integer> set = new HashSet<>();

        int curWord;
        int ans = 0;
        for (int i = 0; i < n; i++) {
            curWord = sc.nextInt();

            if (!set.contains(curWord)) {
                ans++;
                if (queue.size() == m) {
                    set.remove(queue.poll());
                }
                set.add(curWord);
                queue.offer(curWord);
            }
        }

        System.out.println(ans);
    }

    static class Input {
        StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));

        public int nextInt() {
            try {
                in.nextToken();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return (int) in.nval;
        }
    }
}
